﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyBank
{
    public class User
    {
        //姓名
        private string _name;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        //密码
        private string _password;

        public string Password
        {
            get { return _password; }
            set { _password = value; }
        }

        //身份证号
        private string _identityNum;

        public string IdentityNum
        {
            get { return _identityNum; }
            set { _identityNum = value; }
        }

        //余额
        private double _blance;

        public double Blance
        {
            get { return _blance; }
            set { _blance = value; }
        }

        //账号
        private string _account; //1000

        public string Account
        {
            get { return _account; }
            set { _account = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="money"></param>
        /// <returns>返回余额，输入有误就返回-1</returns>
        public double MinusMoney(double money) //500
        {
            if (money>0)
            {
                if (money <= _blance)
                {
                    _blance = _blance - money; // 1000 - 500
                    return _blance;
                }
                else
                {
                    return -1;
                }
            }
            else
            {
                return -1;
            }
        }

        public double SaveMoney(double money)
        {
            if (money > 0)
            {
                _blance = _blance + money;
                return _blance;
            }
            else
            {
                return -1;
            }
            
        }

    }
}
